package com.frinder.robot;

import com.frinder.base.akka.Actors;
import com.frinder.robot.handler.RobotManagerActor;
import com.frinder.robot.handler.RobotTaskManagerActor;
import com.frinder.robot.handler.task.RobotTask;
import com.frinder.robot.wx.MapMessageActor;
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @ClassName Starter
 * @Description //TODO
 * @Author frinder
 * @Date 2019/1/19 16:59
 * @Version 1.0
 */
@Slf4j
@Order(3)
@Component("robotStarter")
public class Starter implements CommandLineRunner {

    @Autowired
    private Actors actors;

    @Override
    public void run(String... strings) {
        actors.getActorRef("mapMessageActor", MapMessageActor.NAME);
        actors.getActorRef("robotTaskManagerActor", RobotTaskManagerActor.NAME);
        actors.getActorRef("robotManagerActor", RobotManagerActor.NAME);
    }

    @Bean("RobotTasks")
    public Map<String, RobotTask> RobotTasks() {
        return Maps.newConcurrentMap();
    }
}
